﻿using Ewk.MachineLearning.Genetic.Programming.Program;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.MachineLearning.Genetic.Programming.UnitTests.Program
{
    [TestClass]
    public class VariableNodeUnitTest : ProgramUnitTestBase
    {
        [TestMethod]
        public void The_Value_Of_A_VariableNode_Is_The_Value_That_Was_Passed_To_Its_SetValue_Method()
        {
            const int value = 5;
            var node = new VariableNode(Int);
            
            node.SetValue(value);

            Assert.AreEqual(value, node.GetValue());
        }

        [TestMethod]
        public void When_A_VariableNode_Is_Cloned_Its_Clone_Is_The_Same_Instance()
        {
            var node = new VariableNode(Int);
            
            var result = node.Clone() as VariableNode;

            Assert.IsNotNull(result);
            Assert.IsTrue(ReferenceEquals(node, result));
        }

        [TestMethod]
        public void When_A_VariableNode_Is_Cloned_Its_Clone_Has_The_Same_Value()
        {
            var node = new VariableNode(Int);
            node.SetValue(5);

            var result = node.Clone() as VariableNode;

            Assert.IsNotNull(result);
            Assert.AreEqual(node.GetValue(), result.GetValue());
        }
    }
}